﻿@using PopForums.Controllers;
@using PopForums.Extensions;
@model ICollection<Microsoft.Owin.Security.AuthenticationDescription>
@{
    ViewBag.Title = PopForums.Resources.Login;
    Layout = "~/Areas/PopForums/Views/Shared/PopForumsMaster.cshtml";
}

@section HeaderContent
{
	<script language="javascript" type="text/javascript">
		$(function () {
			$("#LoginButton").click(PopForums.processLogin);
			$("#EmailLogin,#PasswordLogin").keydown(function (e) { if (e.keyCode == 13) PopForums.processLogin(); });
		});
	</script>
}

<div id="TopBreadcrumb" class="navAbsolute">
	<h1>@PopForums.Resources.Login</h1>
	<p>
		^ @Html.ActionLink(PopForums.Resources.Forums, "Index", ForumHomeController.Name, null, null)
	</p>
</div>

@if (this.GetUserFromViewData() == null)
{
<table class="account">
	<tr>
		<td colspan="2"><span id="LoginResult" class="warning">@Request.QueryString["error"]</span></td>
	</tr>
	<tr>
		<td>@PopForums.Resources.Email</td>
		<td>@Html.TextBox("EmailLogin")</td>
	</tr>
	<tr>
		<td>@PopForums.Resources.Password</td>
		<td>@Html.Password("PasswordLogin")</td>
	</tr>
	<tr>
		<td></td>
		<td>@Html.CheckBox("PersistCookie") <label for="PersistCookie">@PopForums.Resources.RememberMe</label></td>
	</tr>
	<tr>
		<td></td>
		<td><input id="LoginButton" type="button" value="@PopForums.Resources.Login" /></td>
	</tr>
</table>

if (Model.Count > 0)
{
	using (Html.BeginForm("ExternalLogin", "Authorization", new { ReturnUrl = ViewBag.Referrer }))
	{
		@Html.AntiForgeryToken()
		<h2>@PopForums.Resources.ExternalLogins</h2>
		<p>
			@foreach (var authenticationDescription in Model)
			{
				<button type="submit" id="@authenticationDescription.AuthenticationType" name="provider" value="@authenticationDescription.AuthenticationType">@authenticationDescription.AuthenticationType</button>
			}
		</p>
	}
}
    
<p>@PopForums.Resources.NotRegisteredQuestion @Html.ActionLink(PopForums.Resources.CreateAnAccount, "Create", AccountController.Name). @Html.ActionLink(PopForums.Resources.ForgotPasswordQuestion, "Forgot", AccountController.Name)</p>

@Html.Hidden("Referrer", (object)ViewBag.Referrer)
}
else
{
	<p>@PopForums.Resources.LoginAlready</p>
}